/**
 * $Id$ Copyright 2009-2012 Oak Pacific Interactive. All rights reserved.
 */
package com.shuqi.common.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.text.TextUtils;

public class RegexUtil {

    // 判断邮箱格式是否正确
    public static boolean isEmail(String email) {
        if (!TextUtils.isEmpty(email)) {
            String patternEmail =
                    "^[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$";
            Pattern regex = Pattern.compile(patternEmail);
            Matcher matcher = regex.matcher(email);
            return matcher.matches();
        }
        return false;
    }

    // 判断密码格式是否正确
    public static boolean isPassword(String pwd) {
        String pattern = "^[\\da-zA-Z]{6,16}$";
        if (!TextUtils.isEmpty(pwd)) {
            Pattern regex = Pattern.compile(pattern);
            Matcher matcher = regex.matcher(pwd);
            return matcher.matches();
        }
        return false;
    }

    // 判断手机格式是否正确
    public static boolean isMobileNO(String mobiles) {
        Pattern p = Pattern.compile("^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\\d{8}$");
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }


}
